﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using VisualWip.Core.Interfaces;

namespace VisualWip.Core
{
    public class WorkItem
    {
        private readonly Collection<IWorkItemBehavior> _behaviors;
        private readonly Collection<WorkItem> _children;

        public WorkItem()
        {
            Fields = new Dictionary<string, object>();
            _children = new Collection<WorkItem>();
            _behaviors = new Collection<IWorkItemBehavior>();
        }

        public virtual string TypeName { get; set; }
        public virtual string Id { get; set; }
        public virtual string Title { get; set; }
        public virtual string State { get; set; }
        public virtual IDictionary<string, object> Fields { get; private set; }

        public virtual IEnumerable<WorkItem> Children
        {
            get { return _children; }
        }

        public virtual IEnumerable<IWorkItemBehavior> Behaviors
        {
            get { return _behaviors; }
        }

        public void AddBehavior(IWorkItemBehavior workItemBehavior)
        {
            _behaviors.Add(workItemBehavior);
        }

        public void AddChild(WorkItem childWorkItem)
        {
            _children.Add(childWorkItem);
        }
    }
}